﻿$(function () { });

function save() {
    var id = $("#hdnRoleId").val();
    var roleName = $("#txtRoleName").val();
    var roleCode = $("#txtRoleCode").val();
    var sort = $("#txtSort").val();

    if (IsEmpty(roleName)) {
        $.ligerDialog.error("角色名称不能为空");
        $("#txtRoleName").focus();
        return;
    }
    if (IsEmpty(roleCode)) {
        $.ligerDialog.error("角色编码不能为空");
        $("#txtRoleCode").focus();
        return;
    }

    $.ajax({
        url: "/Sysbase/Role/Save",
        type: "post",
        data: {
            Id: id,
            RoleName: roleName,
            RoleCode: roleCode,
            Sort: sort
        },
        success: function (r) {
            var r = $.parseJSON(r);
            if (r.Result == 1) {
                parent.$("#btnSearch").click();
                closeDialog();
            }
            else if (r.Result == 0) {
                $.ligerDialog.error(r.Body);
            }
            else {
                $.ligerDialog.error("程序错误");
            }
        },
        error: function () {
            $.ligerDialog.error("程序错误");
        }
    });
}

function closeDialog() {
    frameElement.dialog.close();//关闭dialog
}